﻿using System.Net;

namespace HenrryTools.Common
{
    /// <summary>  
    /// 共用工具类  
    /// </summary> 
    public class IpHelper
    {
        #region 获得用户IP  
        /// <summary>  
        /// 获得用户IP  
        /// </summary>  
        public static string GetUserIp()
        {
            ///获取本地的IP地址
            string AddressIP = string.Empty;
            foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
            {
                if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
                {
                    AddressIP = _IPAddress.ToString();
                }
            }
            return AddressIP;
        }
        #endregion

        #region 获取本机的计算机名  
        /// <summary>  
        /// 获取本机的计算机名  
        /// </summary>  
        public static string LocalHostName
        {
            get
            {
                return Dns.GetHostName();
            }
        }
        #endregion
    }
}
